package com.zhuman.controller;

import com.google.gson.JsonObject;
import com.zhuman.entity.Entity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@RequestMapping(value = "/search")
public class HomeController {

    @RequestMapping(value = "/goo", method = RequestMethod.GET)
    @ResponseBody
    public Entity doSearch(@RequestParam("id") String id) {
       Entity entity = new Entity();
        if(id!=null||id!="") {
            entity.setId(Integer.parseInt(id));
            if (entity.getId() == 1) {
                entity.setAddress("hz");
                entity.setName("zhangsan");
            }
        }

        return entity;
    }
    @RequestMapping(value = "/go", method = RequestMethod.POST)
    @ResponseBody
    public Entity doResearch(@RequestBody Entity entity) {
        //Entity entity = new Entity();
            if (entity.getId() == 1) {
                entity.setAddress("hz");
                entity.setName("zhangsan");
            }
        return entity;
    }
}
